﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class TypeCategoryManager : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            load_AllTypeCategory();
        }
    }

    public void load_AllTypeCategory()
    {
        TypeCategoryRepeater.DataSource = BusLogic.TypeCategory.get_ALL_TYPE_CATEGORY();
        TypeCategoryRepeater.DataBind();
    }
    

    protected void lbtDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in TypeCategoryRepeater.Items)
        {
            CheckBox cb = (CheckBox)item.FindControl("cbxCheckTypeCategory");

            if (cb.Checked == true)
            {
                TextBox txtTypeCategoryId = (TextBox)item.FindControl("txtTypeCategoryId");                
                BusLogic.TypeCategory.remove_TYPE_CATEGORY(int.Parse(txtTypeCategoryId.Text));
            }
        }
        load_AllTypeCategory();
        cbxCheckALLTypeCategory.Checked = false;
    }

    protected void cbxCheckALLTypeCategory_CheckedChanged(object sender, EventArgs e)
    {
        if (cbxCheckALLTypeCategory.Checked == true)
        {
            foreach (RepeaterItem item in TypeCategoryRepeater.Items)
            {
                CheckBox cbxCheckTypeCategory = item.FindControl("cbxCheckTypeCategory") as CheckBox;
                cbxCheckTypeCategory.Checked = true;
            }
        }
        else
        {
            foreach (RepeaterItem item in TypeCategoryRepeater.Items)
            {
                CheckBox cbxCheckTypeCategory = item.FindControl("cbxCheckTypeCategory") as CheckBox;
                cbxCheckTypeCategory.Checked = false;
            }
        }

    }
}
